home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan
/
Opus 5 - Magellan.iso
/
Extras
/
Show&Edit_1.8
/
ARexx
/
Show&Edit.dopus5
next >
Wrap
Text File
|
1997-06-05
|
9KB
|
366 lines
/* $VER: Show&Edit.dopus5 1.8 (22.12.96) Frederic Steinfels
*/
/* History:
...
1.0 Added the BACKGROUND mode (opening a new lister
not to make the current source busy)
1.1 Added the progress bar.
1.2 Switched from 'lister newprogress' to 'dopus progress'
as 'dopus progress' does not make the lister busy.
WHY IS 'DOPUS PROGRESS' NOT MENTIONED IN THE 5.5
MANUAL?
1.3 Implemented workaround to get the selected entries for
both modes (name and icon action). This was necessary
as Dopus doesn't handle rexx commands concerning the
icon mode. :-( :-(
(Before starting the script, all selected entries
are written to a temporary file. This program does no
longer query the selected entries from Arexx, what was,
of course, a faster and better way...)
1.4 Found a better solution. Another Arexx script gets all
the Selected Icons (first) and selects the corresponding
entries in the name mode so that the main script just has
to query them.
1.5 Added numeric count (two lines ;-), Opus is cool )
1.6 Forgot to delete a temporary file.
1.7 Files that included spaces couldn't be opened. Unfortunately
some other special characters could also not work. This
only happens as I had to use the following workaround:
1.8 Switched from SHOWEDIT{Qp}{ou} to SHOWEDIT{Qp}{Ql} and
it's also possible to create the file only once.
Before this wasn't possible due to a bug in Dopus 5.5.
This script is usign this line:
command WAIT source handle dest handle User4 file
This makes the lister with the selected handle executing
the 'User4' command on the file that is contained in
the variable 'file'. As you can start this script
in SHOW/EDIT, ASYNCHRONOUS/SYNCHRONOUS mode, all four
user commands were needed if I didn't use a trick:
The first line of every User4 filetype command has
the line:
Script: "T:SHOWEDIT{Qp}{Ql}"
The {Qp} and {ou} flags are needed as you can start this
script several times in different modes and the name of this
'T:' file must be unique. The file itself contains the
following lines:
set SHOW "RUN <>NIL: "
set EDIT "NOP "
alias SHOW "GET SHOW"
alias EDIT "GET EDIT"
That's the file if you selected the SHOW button in ASYNC
mode. If you select the EDIT button in SYNC mode, the file
contains the following lines:
set SHOW ""
set EDIT "NOP "
alias SHOW "GET SHOW"
alias EDIT "GET EDIT"
and so on. ('NOP' is a program that does nothing. It's again
a workaround as the ';' does not work under these
circumstances. (If you don't believe it, try this:
set bla ";echo" [ENTER] $bla [ENTER]))
The lines that start the show/edit program look like this:
AmigaDOS: `SHOW`something
AmigaDOS: `EDIT`anotherprogram
As I can't use `GET SHOW` directly (it contains a blank
what is illegal) I have to use a alias. This makes
it possible to select the mode a file gets started.
I hope you understand now that it is important that the
file T:SHOWEDIT is unique. Otherwise the programs would
be started in the wrong way if you used this script several
times at once in different modes.
*/
/*
Unfortunately I had to use some 'workarounds' in this script
due to some missing features or bugs. You could say the whole
script is a work-around but with some additional features.
Dopus is only able to do the 'UserX' command (action set in
the filetype) on files in the current directory. It does not
scan for subdirectories even if you selected 'Recursive Dirs'.
You would have to define in the directory file type for 'UserX'
some commands that create a script that scans this subdir
and does 'UserX' on all entries. This is slow and ugly (how
to name and delete these temporary files???) so I decided
to do my own rexx script with all these cool features like:
- starting all files in a row
- starting all files at "once" (ASYNC)
- starting all files at "once" in the Background (from
another lister so that your lister won't be busy.
Unfortunately dopus can't open a lister invisible; I
have to open and THEN hide it)
*/
/* BTW: Do not use the MacSound or MacSnd Datatype (filetype scan
could take some minutes per file). Use a version of the
be.datatype that does not take executables for images and
crash. I think that the SoundModule filetype (delivered
by Opus5.5) does not work and that it has some ugly side
effects like ArcHandler crashing while doubleclicking on
a directory in name mode in an lha archive.
*/
/* The following files are required:
· rexxdossupport.library
Copyright (C) 1994-1997 by Hartmut Goebel, <hartmut@oberon.nbg.sub.org>
· rexxtricks.library
Copyright (C) 1994,95 by Jürgen Kohrmeyer, <J_Kohrmeyer@wilam.north.de>
· DosInfo
Copyright (C) 1992 by Christian A. Weber, <chris@limmat.ch>
· Show&Edit.dopus5
Frédéric Steinfels (fsteinfe@iiic.ethz.ch)
· Nop
Frédéric Steinfels (fsteinfe@iiic.ethz.ch)
*/
signal on BREAK_C
signal on BREAK_D
signal on BREAK_E
signal on BREAK_F
signal on HALT
signal on IOERR
signal on SYNTAX
options failat 21
options results
parse arg arguments
Call Init
address value PORT
Call CheckEntries
Call QueryLister
if BACKGROUND=1 then Call OpenInBG
if dirs.count>0 then Call ScanSubDirs
Call ExecFiles
Call CleanUP
Exit
Unselect:
if POS('/',files.cnt) ~= 0 then do
parse var files.cnt cpath "/" .
if cpath ~= lpath & symbol('lpath')='VAR' then do
lister select handle '"' || lpath || '"' 0
lister refresh handle full
end
lpath=cpath
end
else do
lister 'select' handle '"' || files.cnt || '"' 'off'
lister refresh handle full
end
return
Init:
libname = "rexxdossupport.library"
if ~show("L", libname) then do
if ~addlib(libname, 0, -30, 2) then do
say libname "not added!"
exit
end
end
libname = "rexxtricks.library"
if ~show("L", libname) then do
if ~addlib(libname, 0, -30) then do
say libname "not added!"
exit
end
end
libname = "rexxsupport.library"
if ~show("L", libname) then do
if ~addlib(libname, 0, -30) then do
say libname "not added!"
exit
end
end
ProgramName = "Show&Edit.dopus5";
ArgsTemplate = "PORT/A,HANDLE/A,ASYNC/S,EDIT/S,BACKGROUND/S"
lf='0a'x
if strip(arguments) = '?' then do
call writech(STDOUT, ArgsTemplate || ': ')
pull arguments
end; else nop
if ~ReadArgs(arguments,ArgsTemplate) then do
say Fault(RC,ProgramName)
exit 10
end; else nop
drop arguments
return
CheckEntries:
lister query handle numselentries
if result=0 then exit
return
QueryLister:
lister query handle 'path'
path = result
lister query handle selfiles stem files
if symbol('files.count') = 'LIT' then files.count=0
lister query handle seldirs stem dirs
if symbol('dirs.count') = 'LIT' then dirs.count=0
return
OpenInBG:
Command source handle dest handle wait NONE
lister query handle position
parse var result x "/" y "/" w "/" h " " .
lister new x || "/" || y || "/" || w || "/" || h path
HANDLE=result
lister set handle visible 0
return
ScanSubDirs:
cnt=0
if dirs.count > 0 then do
tmpfile='T:'||handle||RAND(10000000,99999999)
rv=delete(tmpfile)
do until cnt = dirs.count
address command 'cd "' || path || '"' || lf || 'C:list >>"' || tmpfile || '" "' || dirs.cnt || '" ALL FILES SORT NAME LFORMAT "%p%n"'
cnt=cnt+1
end
if open('tmp',tmpfile,'READ') then do
cnt=files.count
do until EOF('tmp')
files.cnt = readln('tmp')
cnt=cnt+1
end
files.count=cnt-1
rv=close('tmp')
rv=delete(tmpfile)
end
end
return
ExecFiles:
address value port
cnt = 0
if open('SE','T:SHOWEDIT'||PORT||HANDLE,'WRITE') then do
IF ASYNC=1 then do
IF EDIT=1 then do
rv=writeln('SE','set SHOW "NOP "')
rv=writeln('SE','set EDIT "RUN <>NIL: "')
end
else do
rv=writeln('SE','set SHOW "RUN <>NIL: "')
rv=writeln('SE','set EDIT "NOP "')
end
end
else do
IF EDIT=1 then do
rv=writeln('SE','set SHOW "NOP "')
rv=writeln('SE','set EDIT ""')
end
else do
rv=writeln('SE','set SHOW ""')
rv=writeln('SE','set EDIT "NOP "')
end
end
rv=writeln('SE','alias SHOW "GET SHOW"')
rv=writeln('SE','alias EDIT "GET EDIT"')
rv=close('SE')
SetProtection("T:SHOWEDIT"||PORT||HANDLE,'srwd')
dopus progress name file info bar abort
pghandle=result
if EDIT=0 then do
dopus progress pghandle title 'Showing files...'
end
else do
dopus progress pghandle title 'Editing files...'
end
do while cnt < files.count
dopus progress pghandle name filepart(files.cnt)
dopus progress pghandle info pathpart(files.cnt)
dopus progress pghandle bar files.count cnt+1
dopus progress pghandle file files.count cnt+1
dopus progress pghandle abort
if result ~= 0 then return
If BACKGROUND=0 then Call Unselect
command WAIT source handle dest handle User4 '"' || makepath(path,files.cnt) || '"'
cnt=cnt+1
end
rv=delete("T:SHOWEDIT"||PORT||HANDLE)
IF BACKGROUND=0 then Call UnselectLast
end
return
UnselectLast:
if symbol('cpath') = 'VAR' then do
lister select handle '"' || cpath || '"' 0
lister refresh handle full
end
return
CleanUp:
if BACKGROUND=1 then lister close handle
dopus progress pghandle off
return
ERROR:
HALT:
IOERR:
SYNTAX:
IF RC ~= 0 THEN DO
dopus request '"Error in' ProgramName || lf || errortext(rc) lf 'Line' sigl || '"'
END
else do
dopus request '"Error in' ProgramName
end
BREAK_C:
BREAK_D:
BREAK_E:
BREAK_F:
Call CleanUP
exit 20